<?php


namespace app\user\controller;


use think\Controller;
use think\Db;

class Test extends Controller
{
    public function email(){
        $res = SendEmailOutlook('2761107965@qq.com','1234');
        dump($res);
    }
    public function test1(){
        Db::startTrans();
        Db::name('user_cart')->lock(true)->find(11);
//        Db::name('user_cart')->lock('lock in share mode')->find(11);
        sleep(10);
        Db::commit();
    }

    public function test2(){
        $a = Db::name('user_cart')->find(11);
        dump($a);
        try {
            Db::name('user_cart')->where(['id'=>11])->setInc('num');
            echo 222;
        }catch (\Exception $e){
            echo 3343;
        }

        die;
        $add['user_id'] = 36;
        $add['goods_id'] = 3;
        if (Db::name('user_cart')->insert($add)){
            echo 3;
        }else{
            echo 545;
        }
    }

    public function test3(){
//        $current_map = Db::name('user_map')->where(['map_number'=>'MAP00000001'])->select();
//        $str = array_search('2',array_column($current_map,'position'));
//        dump($str);
//        $add[3]['user_id'] = 3;
//        $add[3]['goods_id'] = 2;
//        $add[2]['user_id'] = 1;
//        $add[2]['goods_id'] = 1;
//        Db::name('user_cart')->insertAll($add);
//        CheckMap(1);

        for ($i=1;$i<=8;$i++){
            $add[$i]['user_id'] = 1;
            $add[$i]['break_from'] = '11111';
            $add[$i]['cycle'] =2;
            $add[$i]['match_type'] = 1;
            $add[$i]['map_number'] = '232323232';
            $add[$i]['map_level'] = 1;
            $add[$i]['position'] = 1;
            $add[$i]['add_time'] = 121212121;
        }
        Db::name('test')->insertAll($add);
    }
}